<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8" />
	<title>验证码</title>
	<style type="text/css">
		/**{
			margin: 0;
			padding: 0;
		}*/
		img{
			width: 80px;
		}
	</style>
	<script type="text/javascript">
		window.onload=function(){
			var oCode=document.getElementById('code');
			var oNew=document.getElementById('new');
			var oVal=document.getElementById('val');
			var oBtn=document.getElementById('btn');
			var codeArr=['jtmy','4a68','fat5','clwk','dmbx'];
			var imgArr=[0,1,2,3,4];
			var suiji=parseInt(Math.random()*imgArr.length);
			oCode.src='img/'+imgArr[suiji]+'.png'
			oNew.onclick=function(){
				suiji=parseInt(Math.random()*imgArr.length)
				oCode.src='img/'+imgArr[suiji]+'.png'
			}
			oBtn.onclick=function(){
				if(oVal.value.toLowerCase()==codeArr[suiji].toLowerCase()){
					alert('成了！')
				}
				else{
					alert('验证码错误！')
				}
			}
		}
	</script>
</head>
<body>
	<form action="#" method="post">
		验证码：<input type="text" id="val" value="" />
		<img id="code"/>
		<input type="button" name="" id="new" value="刷新" /><br />
		<input type="button" name="btn" id="btn" value="提交" />
	</form>
</body>
</html>